package com.llyb.lease.common.minio;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(MinioProperty.class)
@ConditionalOnProperty(prefix = "minio", name = "username")
public class MinConfiguration {

    @Autowired
    private MinioProperty minioProperty;

    @Bean
    public MinioClient minioClient(){
        return MinioClient.builder().endpoint(minioProperty.getEndPoint())
                .credentials(minioProperty.getUsername(),minioProperty.getPassword()).build();
    }
}
